package com.examination.system.administrator.controller;

import com.examination.api.administrator.NationControllerApi;
import com.examination.framework.model.response.QueryResponseResult;
import com.examination.framework.model.response.ResponseResult;
import com.examination.system.administration.Nation;
import com.examination.system.administration.response.AddAdministrationResult;
import com.examination.system.administration.response.DeleteAdministrationResult;
import com.examination.system.administrator.service.NationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author 寇淇芮
 * @Date 2019/8/24 20:19
 */
@RestController
@RequestMapping(value = "/administrator")
public class NationController implements NationControllerApi {
    @Autowired
    private NationService nationService;

    @Override
    @PostMapping("/nation/add")
    public AddAdministrationResult addNation(@RequestBody Nation nation) {
        return nationService.addNation(nation);
    }
    @Override
    @GetMapping("/nation/all")
    public QueryResponseResult<Nation> findNationAll(){
       return   nationService.findNationAll();
    }
    @Override
    @DeleteMapping("/nation/delete/{id}")
    public DeleteAdministrationResult deleteNation(@PathVariable(value = "id") String id) {
        return nationService.deleteNation(id);
    }

    @Override
    @PostMapping("/nation/edit/{id}")
    public ResponseResult editNation(@PathVariable(value = "id") String id,
                                     @RequestBody Nation nation) {
        return nationService.editNation(id,nation);
    }

    @Override
    @GetMapping("/nation/list/{page}/{size}")
    public QueryResponseResult findNationList(@PathVariable( "page" ) Integer page,
                                              @PathVariable("size") Integer size) {
        return nationService.findNationList(page,size);
    }
}
